# coding=utf-8
from django import forms


class GetOrderPreview(forms.Form):
    """
    获取订单预览信息
    """
    typeset_id = forms.IntegerField()
    material_id = forms.IntegerField()
    bind_id = forms.IntegerField()
    font_color_id = forms.IntegerField()


class CreateOrder(forms.Form):
    """
    验证创建订单
    """
    typeset_id = forms.IntegerField()
    material_id = forms.IntegerField()
    bind_id = forms.IntegerField()
    font_color_id = forms.IntegerField()


class GetSutraEditionList(forms.Form):
    """
    验证获取抄写经书版本列表
    """
    type = forms.IntegerField(min_value=0, max_value=2)
    limit = forms.IntegerField(min_value=1, required=False)
    offset = forms.IntegerField(min_value=0, required=False)

    def clean(self):
        cleaned_data = super().clean()
        if not cleaned_data.get("limit"):
            cleaned_data["limit"] = 10
        if not cleaned_data.get("offset"):
            cleaned_data["offset"] = 0


class GetSutraEditionDetail(forms.Form):
    """
    验证获取抄写经书版本详情
    """
    type = forms.IntegerField(min_value=0, max_value=1)
